package org.testile.datasetgenerifier;

import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.ForwardOnlyTable;
import org.dbunit.dataset.ITable;

/**
 *
 * @author amra
 */
public class GenerifiedTable extends ForwardOnlyTable {

	private TableGenerifier tableGenerifier;
	private ITable wrapped;

	public GenerifiedTable(ITable wrapped, TableGenerifier tableGenerifier) {
		this(wrapped);
		this.tableGenerifier = tableGenerifier;
	}

	public GenerifiedTable(ITable wrapped) {
		super(wrapped);
		this.wrapped = wrapped;
	}

	@Override
	public Object getValue(int row, String column) throws DataSetException {
		Object originalValue = wrapped.getValue(row, column);
		ColumnGenerifier columnGenerifier = tableGenerifier.getColumnGenerifier(column);
		return columnGenerifier.generifyValue(String.valueOf(originalValue));
	}
}
